<a href="<?php echo base_url().'poster_admin/upload'?>"><button type="button" class="btn btn-primary btn-lg upload-button">添加作品</button></a>
<div class="right-side selection">
    <div class="btn-group">
        <div class="btn-group">
            <a href="<?=base_url().'poster_admin/works'?>">
            <button type="button" class="btn btn-default">
                查看全部
            </button></a>
        </div>
        <div class="btn-group">
            <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                正在进行
                <span class="caret"></span>
            </button>
            <ul class="dropdown-menu">
                <?php
                    $i = 0;
                    foreach($category as $value) {
                        if ($value['deadline'] - now() > 0) {
                            echo '<li><a href="'.base_url().'poster_admin/works/search?id='.$value['id'].'">'.$value['category'].'</a></li>';
                            $i++;
                        }
                    }
                if ($i == 0)
                    echo '<li><a href="#">暂无</a></li>';
                ?>
            </ul>
        </div>
        <div class="btn-group">
            <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                已结束
                <span class="caret"></span>
            </button>
            <ul class="dropdown-menu">
                <?php
                $i = 0;
                foreach($category as $value) {
                    if ($value['deadline'] - now() < 0) {
                        echo '<li><a href="'.base_url().'poster/admin/search?id='.$value['id'].'">'.$value['category'].'</a></li>';
                        $i++;
                    }
                }
                if ($i == 0)
                    echo '<li><a href="#">暂无</a></li>';
                ?>
            </ul>
        </div>
    </div>
</div>
<h1 id="titlename">全部作品</h1>

<div class="alert clear text-center alert-warning"><p>设置作品前请先确保配置完了学院与分类</p><p>点击图片可查看图片大图</p></div>
<?php
if (!empty($query)) {

foreach($query as $value) {
    echo '<div class="clear"><div class="panel panel-default">
             <div class="panel-body">';
    echo '<a class="fancybox" rel="group" href="'. base_url() . 'uploads/' . $value['filename'] . '"><img class="img-rounded thumb" src="'. base_url() . 'uploads/' . $value['filename'] . '" /></a>';
    echo '<div class="main-inform">';
    echo '作品名：' . $value['title'] . '<br/>';
    echo '作者：' .$value['realname'] . '<br/>';
    echo '学号：' .$value['studentnum'] . '<br/>';
    echo '所属学院：' .$value['name'] . '<br/>';
    echo '参赛项目：' .$value['category']. '<br/>';
    echo '介绍：';
    echo '<blockquote>'.$value['content'].'</blockquote>';
    echo '<a href="'.base_url().'poster_admin/works/edit?pid='.$value['pid'].'"><button type="button" class="btn btn-primary">修改</button></a> ';
    echo ' <button type="button" class="btn btn-danger" data-toggle="modal" data-target="#Delete'.$value['pid'].'">删除</button>';
?>
    <div class="modal fade" id="Delete<?php echo $value['pid'] ?>" tabindex="-1" role="dialog" aria-labelledby="Del<?php echo $value['pid'] ?>" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="Del<?php echo $value['pid'] ?>">确认删除？</h4>
                </div>
                <div class="modal-body">
                    <p>您是否要删除（删除操作不可逆，一旦删除，无法恢复，请谨慎操作）：</p>
                    <?php
                        echo '<div class="panel panel-default">';
                        echo '    <div class="panel-body">';
                        echo '<img class="img-rounded thumb" src="'. base_url() . 'uploads/' . $value['filename'] . '" />';
                        echo '<div class="main-inform">';
                        echo '作品名：' . $value['title'] . '<br/>';
                        echo '作者：' .$value['realname'] . '<br/>';
                        echo '学号：' .$value['studentnum'] . '<br/>';
                        echo '所属学院：' .$value['name'] . '<br/>';
                        echo '参赛项目：' .$value['category']. '<br/>';
                        echo '介绍：';
                        echo '<blockquote>'.$value['content'].'</blockquote>';
                        echo '</div>';
                        echo '</div>';
                        echo '</div>';
                    ?>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <?php     echo '<a href="'.base_url().'poster_admin/works/delete?pid='.$value['pid'].'"><button type="button" class="btn btn-danger">删除</button></a>' . '<br/>'; ?>
                    </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
<?php
    echo '</div>';
    echo '</div></div></div>';
}
} else {
    echo '<div class="clear"><div class="alert alert-danger">目前还没有任何作品的样子，请先添加</div></div>';
}
echo $page;
?>